package View.JPanel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Image;
import java.awt.RenderingHints;
import java.io.File;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.filechooser.FileSystemView;

import org.jdesktop.swingx.JXPanel;
import org.jdesktop.swingx.painter.GlossPainter;

import Management.Animation;

public class JInformationPanel extends JPanel{
	private JPanel right;
	private JPanel center;
	private JPanel left;
	private GlossPainter p;
	private JLabel fileIcon;
	private JLabel nameIcon;
	private JLabel typeIcon;
	private JLabel tagIcon;
	private FileSystemView fsv = FileSystemView.getFileSystemView();
	private File	f;

	public JInformationPanel(File f) {
		this.f = f;
		right = new JPanel();
		right.setOpaque(false);
		center = new JPanel();
		center.setOpaque(false);
		left  = new JPanel();
		left.setOpaque(false);
		fileIcon = new JLabel();
		
		nameIcon = new JLabel(f.getName());
		typeIcon = new JLabel(new Animation(f).getFileType());
		tagIcon  = new JLabel("None");
		right.add(fileIcon);
		center.setLayout(new BorderLayout());
//		nameIcon.setAlignmentX(Component.CENTER_ALIGNMENT);
		center.add("North",nameIcon);
//		typeIcon.setAlignmentX(Component.CENTER_ALIGNMENT);
		center.add(Box.createVerticalGlue());
		center.add("South",typeIcon);
		left.add(tagIcon);
		p = new GlossPainter();
		p.setPaint(new Color(1.0f, 1.0f, 1.0f, 0.5f));
		p.setPosition(GlossPainter.GlossPosition.TOP);
//		setBackgroundPainter(p);
//		setBorder(null);
		setLayout(new BorderLayout());
		add("West",right);
		add("Center",center);
		add("East",left);
	}
	
	/**
	 * set the File
	 */
	public void setF(File f) {
		this.f = f;

		ImageIcon ii = (ImageIcon) fsv.getSystemIcon(f);
		Image image = ii.getImage();
		Image scaledImage = image.getScaledInstance(32, 32, Image.SCALE_AREA_AVERAGING);
		ImageIcon ii2 = new ImageIcon(scaledImage);
		fileIcon.setIcon(ii2);
		nameIcon.setText(f.getName());
		typeIcon.setText(new Animation(f).getFileType());
		tagIcon.setText("None");
	}

	/**
	 * get the File
	 * @return
	 */
	public File getF() {
		return f;
	}
}
